Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable crashtracking without profiler #3826

Merged
merged 17 commits into from
Aug 15, 2024
Merged

Conversation

TonyCTHsu
Copy link
Contributor

@TonyCTHsu TonyCTHsu commented Aug 6, 2024

What does this PR do?

This PR extracts crash tracking capabilities from profiler. This means crash tracking could be enabled without profiler.

@github-actions github-actions bot added core Involves Datadog core libraries profiling Involves Datadog profiling labels Aug 6, 2024
@pr-commenter
Copy link

pr-commenter bot commented Aug 6, 2024

Benchmarks

Benchmark execution time: 2024-08-15 10:38:12

Comparing candidate commit 6f3c5fe in PR branch tonycthsu/crashtracking with baseline commit d2498fb in branch master.

Found 0 performance improvements and 4 performance regressions! Performance is the same for 19 metrics, 2 unstable metrics.

scenario:profiler - Allocations ()

  • 🟥 throughput [-483315.522op/s; -476309.493op/s] or [-11.829%; -11.657%]

scenario:profiler - Allocations (profiling disabled)

  • 🟥 throughput [-734428.822op/s; -728066.018op/s] or [-12.525%; -12.416%]

scenario:profiler - Allocations (profiling enabled)

  • 🟥 throughput [-707964.939op/s; -641404.889op/s] or [-12.299%; -11.143%]

scenario:profiler - sample timeline=false

  • 🟥 throughput [-0.767op/s; -0.732op/s] or [-10.601%; -10.117%]

Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few quick notes!

lib/datadog/core/crashtracking/agent_base_url.rb Outdated Show resolved Hide resolved
lib/datadog/core/crashtracking/component.rb Outdated Show resolved Hide resolved
lib/datadog/core/crashtracking/component.rb Outdated Show resolved Hide resolved
lib/datadog/core/crashtracking/tag_builder.rb Outdated Show resolved Hide resolved
lib/datadog/core/crashtracking/tag_builder.rb Outdated Show resolved Hide resolved
lib/datadog/core/crashtracking/tag_builder.rb Outdated Show resolved Hide resolved
lib/datadog/core/crashtracking/tag_builder.rb Outdated Show resolved Hide resolved
lib/datadog/core/configuration/settings.rb Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Aug 7, 2024

Codecov Report

Attention: Patch coverage is 97.16495% with 11 lines in your changes missing coverage. Please review.

Project coverage is 97.84%. Comparing base (d2498fb) to head (85bd6b8).

Files Patch % Lines
spec/datadog/core/crashtracking/component_spec.rb 95.55% 8 Missing ⚠️
spec/support/crashtracking_helpers.rb 77.77% 2 Missing ⚠️
lib/datadog/core/crashtracking/component.rb 98.07% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3826      +/-   ##
==========================================
+ Coverage   97.83%   97.84%   +0.01%     
==========================================
  Files        1264     1269       +5     
  Lines       75725    75869     +144     
  Branches     3729     3736       +7     
==========================================
+ Hits        74084    74233     +149     
+ Misses       1641     1636       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@TonyCTHsu TonyCTHsu force-pushed the tonycthsu/crashtracking branch 3 times, most recently from c7defa4 to c59c4f3 Compare August 12, 2024 15:20
@TonyCTHsu TonyCTHsu marked this pull request as ready for review August 13, 2024 11:32
@TonyCTHsu TonyCTHsu requested review from a team as code owners August 13, 2024 11:32
@TonyCTHsu TonyCTHsu self-assigned this Aug 13, 2024
Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran out of time for now, here's 1/3 of a review, I'll come back for the other files soon :)

.gitlab-ci.yml Outdated Show resolved Hide resolved
lib/datadog/core/configuration/settings.rb Show resolved Hide resolved
lib/datadog/core/crashtracking/component.rb Outdated Show resolved Hide resolved
lib/datadog/core/crashtracking/component.rb Outdated Show resolved Hide resolved
lib/datadog/core/crashtracking/component.rb Show resolved Hide resolved
lib/datadog/core/crashtracking/tag_builder.rb Outdated Show resolved Hide resolved
lib/datadog/core/crashtracking/tag_builder.rb Outdated Show resolved Hide resolved
lib/datadog/core/crashtracking/tag_builder.rb Outdated Show resolved Hide resolved
lib/datadog/profiling/component.rb Outdated Show resolved Hide resolved
@TonyCTHsu TonyCTHsu force-pushed the tonycthsu/crashtracking branch from 3ada1aa to 6cb7c4c Compare August 14, 2024 09:21
@TonyCTHsu TonyCTHsu enabled auto-merge August 14, 2024 10:42
Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got through the whole set of changes now, here's a few notes :)

spec/datadog/core/crashtracking/tag_builder_spec.rb Outdated Show resolved Hide resolved
sig/datadog/core/configuration/settings.rbs Outdated Show resolved Hide resolved
sig/datadog/core/crashtracking/agent_base_url.rbs Outdated Show resolved Hide resolved
sig/datadog/core/crashtracking/component.rbs Outdated Show resolved Hide resolved
lib/datadog/core/configuration/components.rb Show resolved Hide resolved
spec/datadog/core/crashtracking/component_spec.rb Outdated Show resolved Hide resolved
spec/datadog/core/crashtracking/component_spec.rb Outdated Show resolved Hide resolved
spec/datadog/core/crashtracking/component_spec.rb Outdated Show resolved Hide resolved
@TonyCTHsu TonyCTHsu disabled auto-merge August 14, 2024 15:13
Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

spec/datadog/core/crashtracking/component_spec.rb Outdated Show resolved Hide resolved
spec/support/crashtracking_helpers.rb Show resolved Hide resolved
lib/datadog/core/crashtracking/component.rb Outdated Show resolved Hide resolved
spec/datadog/core/crashtracking/component_spec.rb Outdated Show resolved Hide resolved
spec/datadog/core/crashtracking/component_spec.rb Outdated Show resolved Hide resolved
end
end

def build_crashtracker(options = {})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Avoid using a hash as an optional parameter (...read more)

The rule "Avoid hash optional parameters" is a guideline that encourages developers to explicitly declare parameters instead of using a hash for optional parameters. This is because using a hash for optional parameters can make the code harder to understand and maintain. It can also lead to unexpected behavior if a developer accidentally includes a key in the hash that the method does not expect.

This rule is important because it promotes code readability and maintainability. It also helps prevent potential bugs that may occur due to unexpected keys in the optional hash. By explicitly declaring each parameter, developers can easily see what parameters a method expects, making the code easier to read and understand.

To adhere to this rule, instead of using a hash for optional parameters, explicitly declare each parameter in the method definition. For example, instead of using options = {} in the method definition, declare each parameter like name, email, age. This way, anyone reading the code can easily understand what parameters the method expects and in what order.

View in Datadog  Leave us feedback  Documentation


let(:agent_base_url) { "http://#{hostname}:#{port}" }

[:fiddle, :signal].each do |trigger|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Quality Violation

Suggested change
[:fiddle, :signal].each do |trigger|
%i[fiddle signal].each do |trigger|
Consider using the %i syntax instead (...read more)

The rule "Prefer %i to the literal array syntax" is a guideline that encourages the use of the %i syntax for arrays of symbols. This is a part of the Ruby style guide that aims to promote conciseness and readability.

Symbols are immutable, reusable objects often used in Ruby instead of strings when the value does not need to be changed. When declaring an array of symbols, using the %i syntax can make your code cleaner and easier to read.

To adhere to this rule, instead of declaring an array of symbols using the literal array syntax like [:foo, :bar, :baz], use the %i syntax like %i[foo bar baz]. It's a good practice to consistently use %i for arrays of symbols as it enhances code readability and maintainability.

View in Datadog  Leave us feedback  Documentation

@TonyCTHsu TonyCTHsu force-pushed the tonycthsu/crashtracking branch from 0d915c6 to 11ee87c Compare August 15, 2024 09:53
@TonyCTHsu TonyCTHsu force-pushed the tonycthsu/crashtracking branch from 11ee87c to 6f3c5fe Compare August 15, 2024 10:00
Comment on lines +111 to +115
datadog_gem_path = versioned_path.join("gems/datadog-#{ENV.fetch('RUBY_PACKAGE_VERSION')}")
libdatadog_so_file = "libdatadog_api.#{RUBY_VERSION[/\d+.\d+/]}_#{RUBY_PLATFORM}.so"
unless File.exist?("#{datadog_gem_path}/lib/#{libdatadog_so_file}")
raise "Missing #{libdatadog_so_file} in #{datadog_gem_path}."
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also get this check by setting the DD_FAIL_INSTALL_IF_MISSING_EXTENSION env variable to "true" when calling gem install :)

Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

'version' => settings.version,
'git.repository_url' => Environment::Git.git_repository_url,
'git.commit.sha' => Environment::Git.git_commit_sha,
'is_crash' => true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I was talking with @sanchda about this yesterday and he mentioned libdatadog wasn't adding these automatically.

In Python we also add severity:crash (see DataDog/dd-trace-py#10199 ). I was planning on doing a PR to add this one as well, but in case you want to go ahead ;)

@TonyCTHsu TonyCTHsu merged commit 1402a32 into master Aug 15, 2024
185 of 186 checks passed
@TonyCTHsu TonyCTHsu deleted the tonycthsu/crashtracking branch August 15, 2024 10:46
@github-actions github-actions bot added this to the 2.3.0 milestone Aug 15, 2024
@TonyCTHsu TonyCTHsu mentioned this pull request Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Involves Datadog core libraries profiling Involves Datadog profiling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants